import Util from "../core/Util";
import GlobalData  from "../core/global";

/**
 *
 *  
*/
export class BaseRuntime extends Laya.Sprite {
    onAwake(): void {
        Util.initPerfabs(this);
        this.on("mm_click", this, this._onclick);
    }

    onDestroy(): void {
        this.off('mm_click', this, this._onclick);
    }

    protected _onclick(name: string): void {
        let func = name + "Click";
        if (this[func]) {
            this[func].call(this);
        } else {
            console.log("no event handler:" + func);
        }
    }

    closeClick() {
        GlobalData.instance.popupLayer.close(this);
    }
}
